home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Libraries / MacOS 68K / MathLib68K / MathLib68K Sources / fenv68k_glue.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  2.8 KB  |  199 lines  |  [TEXT/MMCC]

  1. /*
  2.  *    fenv.h glue functions ...
  3.  */
  4.  
  5. #ifndef __SANE__
  6. #include <SANE.h>
  7. #endif
  8.  
  9. #ifndef __FENV__
  10. #include <fenv.h>
  11. #endif
  12.  
  13. #define unused(x) &x
  14.  
  15. #if __MC68881__
  16.  
  17. fenv_t _FE_DFL_ENV = {0,0};
  18.  
  19. void feclearexcept ( int /*excepts*/ )
  20. {
  21.     /* NOT YET IMPLEMENTED */
  22. }
  23.  
  24. void fegetexcept ( fexcept_t */*flagp*/, int /*excepts*/ )
  25. {
  26.     /* NOT YET IMPLEMENTED */
  27. }
  28.  
  29. void feraiseexcept ( int /*excepts*/ )
  30. {
  31.     /* NOT YET IMPLEMENTED */
  32. }
  33.  
  34. void fesetexcept ( const fexcept_t */*flagp*/, int /*excepts*/ )
  35. {
  36.     /* NOT YET IMPLEMENTED */
  37. }
  38.  
  39. int fetestexcept ( int /*excepts*/ )
  40. {
  41.     /* NOT YET IMPLEMENTED */
  42.     return 0;
  43. }
  44.  
  45. int fegetround ( void )
  46. {
  47.     return(GetRound());
  48. }
  49.  
  50. int fesetround ( int round )
  51. {
  52.     RoundDir rounddir=round;
  53.  
  54.     if ((rounddir == FE_TONEAREST) || (rounddir == FE_UPWARD) ||
  55.         (rounddir == FE_DOWNWARD)  || (rounddir == FE_TOWARDZERO))
  56.     {
  57.         SetRound(rounddir);
  58.         return 1;
  59.     }
  60.     else
  61.         return 0;
  62. }
  63.  
  64. void fegetenv ( fenv_t */*envp*/ )
  65. {
  66.     /* NOT YET IMPLEMENTED */
  67. }
  68.  
  69. int feholdexcept ( fenv_t */*envp*/ )
  70. {
  71.     /* NOT YET IMPLEMENTED */
  72.     return 1;
  73. }
  74.  
  75. void fesetenv ( const fenv_t */*envp*/ )
  76. {
  77.     /* NOT YET IMPLEMENTED */
  78. }
  79.  
  80. void feupdateenv ( const fenv_t */*envp*/ )
  81. {
  82.     /* NOT YET IMPLEMENTED */
  83. }
  84.  
  85. int fegetprec ( void )
  86. {
  87.     return((int)GetPrecision());
  88. }
  89.  
  90. int fesetprec ( int precision )
  91. {
  92.     RoundPre roundpre=precision;
  93.  
  94.     if ((roundpre == FE_FLTPREC) || (roundpre == FE_DBLPREC) ||
  95.         (roundpre == FE_LDBLPREC))
  96.     {
  97.         SetPrecision(roundpre);
  98.         return 1;
  99.     }
  100.     else
  101.         return 0;
  102. }
  103.  
  104. #else    /* SANE */
  105.  
  106. fenv_t _FE_DFL_ENV = 0;
  107.  
  108. void feclearexcept ( int /*excepts*/ )
  109. {
  110.     /* NOT YET IMPLEMENTED */
  111. }
  112.  
  113. void fegetexcept ( fexcept_t */*flagp*/, int /*excepts*/ )
  114. {
  115.     /* NOT YET IMPLEMENTED */
  116. }
  117.  
  118. void feraiseexcept ( int /*excepts*/ )
  119. {
  120.     /* NOT YET IMPLEMENTED */
  121. }
  122.  
  123. void fesetexcept ( const fexcept_t */*flagp*/, int /*excepts*/ )
  124. {
  125.     /* NOT YET IMPLEMENTED */
  126. }
  127.  
  128. int fetestexcept ( int /*excepts*/ )
  129. {
  130.     /* NOT YET IMPLEMENTED */
  131.     return 0;
  132. }
  133.  
  134. int fegetround ( void )
  135. {
  136.     return(GetRound());
  137. }
  138.  
  139. int fesetround ( int round )
  140. {
  141.     RoundDir rounddir=round;
  142.  
  143.     if ((rounddir == FE_TONEAREST) || (rounddir == FE_UPWARD) ||
  144.         (rounddir == FE_DOWNWARD)  || (rounddir == FE_TOWARDZERO))
  145.     {
  146.         SetRound(rounddir);
  147.         return 1;
  148.     }
  149.     else
  150.         return 0;
  151. }
  152.  
  153. void fegetenv ( fenv_t *envp )
  154. {
  155.     GetEnvironment(envp);
  156. }
  157.  
  158. int feholdexcept ( fenv_t *envp )
  159. {
  160.     fenv_t env;
  161.  
  162.     GetEnvironment(envp);
  163.     env=*envp;
  164.     env &= ~(FE_ALL_EXCEPT << 8);
  165.     SetEnvironment(&env);
  166.     return 1;
  167. }
  168.  
  169. void fesetenv ( const fenv_t *envp )
  170. {
  171.     SetEnvironment((fenv_t *)envp);
  172. }
  173.  
  174. void feupdateenv ( const fenv_t * envp )
  175. {
  176.     ProcExit((fenv_t *)envp);
  177. }
  178.  
  179. int fegetprec ( void )
  180. {
  181.     return((int)GetPrecision());
  182. }
  183.  
  184. int fesetprec ( int precision )
  185. {
  186.     RoundPre roundpre=precision;
  187.  
  188.     if ((roundpre == FE_FLTPREC) || (roundpre == FE_DBLPREC) ||
  189.         (roundpre == FE_LDBLPREC))
  190.     {
  191.         SetPrecision(roundpre);
  192.         return 1;
  193.     }
  194.     else
  195.         return 0;
  196. }
  197.  
  198. #endif
  199.